<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="/css/elementUI.css">
    <script src="/js/vue.js"></script>
    <script src="/js/elementUI.js"></script>
    <script src="/js/axios.js"></script>
</head>
<body>



<div id="app">


    用户名：<el-input style="width: 200px;" v-model="user.username" placeholder="用户名" clearable></el-input>
    <br>
    密码：<el-input style="width: 200px;" v-model="user.password" placeholder="密码" show-password clearable></el-input>
    <br>
    <el-button @click="toLogin">登录</el-button>







</div>
<script>
    new Vue({
        el:"#app",
        data:{

            user:{
                username:"",
                password:""
            }

        },
        watch:{
        },
        methods:{
            toLogin(){
                axios.post("/user/login",this.user).then(res=>{

                    if(res.data.id){
                        this.$message.success("登录成功")


                        localStorage.setItem("user",JSON.stringify(res.data))


                        location.href = "huodongList.html"

                    }else{
                        this.$message.error(res.data)
                    }

                })
            }

        },
        created(){
        }
    })
</script>



</body>
</html>